import java.util.Arrays;

public class project {
    public int numberOfWeakCharacters(int[][] properties) {
        Arrays.sort(properties,(o1,o2)->{
            return o1[0]!=o2[0]?o2[0]-o1[0]:o1[1]-o2[1];
        });
        int sum=0;
        int max=0;
        for(int[] arr : properties){
            if(arr[1]<max){
                sum++;
            }else{
                max=arr[1];
            }
        }
        return sum;
    }
}
